<?php
session_start();
if(!ob_start("ob_gzhandler")) ob_start();
?>
<html>
	<head>
		<title></title>
		<link rel = "stylesheet" type = "text/css" href = "topBar.css">
		<link rel = "stylesheet" type = "text/css" href = "jquery-ui-1.8.18.custom.css">
		<link rel = "stylesheet" type = "text/css" href = "mainFrame.css">
		<script type="text/javascript" src="jquery-1.7.js"></script>
		<script type = "text/javascript" src = "jquery-ui-1.8.16.custom.min.js"></script>
		<script type = "text/javascript" src = "mainTabScript.js"></script>
	</head>
		<body>
		<?php
	mysql_connect("localhost", "sapmenet_admin", "a1s2d3f4g5h6j7") or die ("Problem with datebase");
	mysql_select_db("sapmenet_users");
	if (isset($_SESSION['JID']))
	{
	
	}
	else{
		header ('Location: ..\index.php');
		exit();
	}
	?>
		<div id = "topBar">
			<div id = "iconsContainer">
				<div class = "icon" id = "advSearchBut">
					<img src = "advancedSearchIcon.png" class = "barIcons" title = "Advanced search">
				</div>
				<div class = "icon" id = "frReqBut">
					<img src = "profile.png" class = "barIcons" title = "Friendship Requests">
				</div>
				<div class = "icon" id = "newsBut">
					<img src = "news.png" class = "barIcons" title = "News">
				</div>
				<div class = "icon" id = "mesBut">
					<img src = "messages.png" class = "barIcons" title = "Messages">
				</div>
			</div>
			<input type = "text" id = "searchBox"><button id = "searchButton"><img src = "Icons/magnifying-glass.gif"></button>
			<div id = 'logo' title = 'Home' onclick = "refresh()"></div>
			<div id='logout' style='position: absolute; right: 20px; top: 3px;'><a href='logout.php' style=' text-decoration: none; color: #b8b8b8;'>Log Out</a></div>
				
		</div>
		<script>
			$.post("notificationChecker.php", function(data)
			{
				if(data != "HUI")
				{
					$("#newsBut").css("box-shadow", "0 0 5px 1px #0f0");
					$("#newsBut").css("-moz-box-shadow", "0 0 5px 1px #080");
				}
				else
				{
					$("#newsBut").css("box-shadow", "none");
					$("#newsBut").css("-moz-box-shadow", "none");
				}
			});
			var to = $(".chatWindowHeader").attr("id");
			$.post("checkForNewMessagesFromOtherUsers.php", {opened : to},function(data)
			{
				if(data != "HUI")
				{
					$("#mesBut").css("box-shadow", "0 0 5px 1px #0f0");
					$("#mesBut").css("-moz-box-shadow", "0 0 5px 1px #080");
				}
				else
				{
					$("#mesBut").css("box-shadow", "none");
					$("#mesBut").css("-moz-box-shadow", "none");
				}
			});
			$.post("checkForRequests.php", function(data)
			{
				if(data!="HUI")
				{
					$("#frReqBut").css("box-shadow", "0 0 5px 1px #0f0");
					$("#frReqBut").css("-moz-box-shadow", "0 0 5px 1px #080");
				}
				else
				{
					$("#frReqBut").css("box-shadow", "none");
					$("#frReqBut").css("-moz-box-shadow", "none");
				}
			});
			$("#searchBox").autocomplete();
			var id = "<?= $_SESSION['JID']?>";
			function refresh()
			{
				window.location = "http://sapme.net/Framework/profilePage.php?id="+id;
			}
			$("#searchBox").keypress(function()
			{
				var inBox = $("#searchBox").val();
				var theSource;
				$.post("autoCompleteSource.php", {name : inBox}, function(data)
				{
					theSource = data.split(",");
					$("#searchBox").autocomplete({source:theSource});
				});
			});
			$("#searchButton").click(function()
			{
				var inBox = $("#searchBox").val();
				$.post("search.php", {name : inBox}, function(data)
				{
					$('#mainFrame').html(data);
				})
			});
			setInterval("tva()", 16000);
			function tva()
			{
				$.post("notificationChecker.php", function(data)
			{
				if(data != "HUI")
				{
					$("#newsBut").css("box-shadow", "0 0 5px 1px #0f0");
					$("#newsBut").css("-moz-box-shadow", "0 0 5px 1px #080");
				}
				else
				{
					$("#newsBut").css("box-shadow", "none");
					$("#newsBut").css("-moz-box-shadow", "none");
				}
			});
			}
			function onova()
			{
				var to = $(".chatWindowHeader").attr("id");
				$.post("checkForNewMessagesFromOtherUsers.php", {opened : to},function(data)
				{
					if(data != "HUI")
					{
						$("#mesBut").css("box-shadow", "0 0 5px 1px #0f0");
						$("#mesBut").css("-moz-box-shadow", "0 0 5px 1px #080");
					}
					else
					{
						$("#mesBut").css("box-shadow", "none");
						$("#mesBut").css("-moz-box-shadow", "none");
					}
				});
			}
			setInterval("onova()", 16000);
			function tretoto()
			{
				$.post("checkForRequests.php", function(data)
				{
					if(data!="HUI")
					{
						$("#frReqBut").css("box-shadow", "0 0 5px 1px #0f0");
						$("#frReqBut").css("-moz-box-shadow", "0 0 5px 1px #080");
					}
					else
					{
						$("#frReqBut").css("box-shadow", "none");
						$("#frReqBut").css("-moz-box-shadow", "none");
					}
				});
			}
			setInterval("tretoto()", 16000);
		</script>
		</body>
</html>		





























